package 草稿包;

import java.util.Scanner;

public class ReverseString {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        // 读取反转后的串的长度n和反转的次数m
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        
        // 读取01串
        char[] string = new char[n];
        String input = scanner.next();
        for (int i = 0; i < n; i++) {
            string[i] = input.charAt(i);
        }
        
        // 接下来m行，每行两个整数l和r，表示反转的区间
        for (int i = 0; i < m; i++) {
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            reverseAndInvert(string, l - 1, r - 1); // 区间反转并取反
        }
        
        // 输出最终的字符串
        System.out.println(string);
        scanner.close();
    }

    // 反转并取反指定区间的字符串
    private static void reverseAndInvert(char[] string, int left, int right) {
        left-=1;
        right-=1;
        while (left < right) {
            // 交换左右字符
            char temp = string[left];
            string[left] = string[right];
            string[right] = temp;
            
            // 取反左右字符
            string[left] = (char) (string[left] == '0' ? '1' : '0');
            string[right] = (char) (string[right] == '0' ? '1' : '0');
            
            left++;
            right--;
        }
        // 如果left == right，只需要取反该位置的字符
        if (left == right) {
            string[left] = (char) (string[left] == '0' ? '1' : '0');
        }
    }
}